import 'package:flutter/material.dart';

class FotterHeader extends StatefulWidget {
  @override
  _FotterHeaderState createState() => _FotterHeaderState();
}

class _FotterHeaderState extends State<FotterHeader>
    with SingleTickerProviderStateMixin {
  AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this);
    // 列表项
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('List Add HeaderView'),
      ),
      body: CustomScrollView(
        slivers: <Widget>[
          // 如果不是Sliver家族的Widget，需要使用SliverToBoxAdapter做层包裹
          SliverToBoxAdapter(
            child: Container(
              height: 120,
              color: Colors.green,
              child: Text(
                'HeaderView',
                style: TextStyle(color: Colors.red, fontSize: 20),
              ),
            ),
          ),
          // 当列表项高度固定时，使用 SliverFixedExtendList 比 SliverList 具有更高的性能
          SliverFixedExtentList(
              delegate:
                  SliverChildBuilderDelegate(_buildListItem, childCount: 18),
              itemExtent: 48.0),

          SliverToBoxAdapter(
            child: Container(
              height: 120,
              color: Colors.green,
              child: Text(
                'FotterView',
                style: TextStyle(color: Colors.red, fontSize: 20),
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildListItem(BuildContext context, int index) {
    return ListTile(title: Text('list tile index $index'));
  }
}
